<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML>
<html>
<head>
	<meta charset="UTF-8">
	<title>pig书屋--用户登录</title>
	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" media="all">
	<link rel="stylesheet" type="text/css" href="css/qian.css" media="all">
	<script type="text/javascript" src="js/jquery.min.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
</head>
<body>
	<div class="container">
		<%@ include file="include/top.jsp" %>

		<div class="content" style="margin:0px 10px;">
			<ul class="breadcrumb">
			  <li><a href="/home.action">首页</a> <span class="divider">/</span></li>
			  <li class="active">用户登录</li>
			</ul>
			<form class="form-horizontal fm" method="post" action="/accountLogin.action">
			<c:choose>
					<c:when test="${param.code == '1001' }">
						<div class="alert alert-error">
						  <button type="button" class="close" data-dismiss="alert">&times;</button>
						  账号或密码错误
						</div>
					</c:when>
					<c:when test="${param.code == '1003' }">
						<div class="alert alert-error">
						  <button type="button" class="close" data-dismiss="alert">&times;</button>
						该账号已被禁用
						</div>
					</c:when>
					<c:when test="${param.code == '1002' }">
						<div class="alert alert-error">
						  <button type="button" class="close" data-dismiss="alert">&times;</button>
						您还没有登录,请先登录
						</div>
					</c:when>
				</c:choose>
			<!-- 在jsp中取用URL中的参数，等于：== -->
			<c:if test="${param.code=='10001'}">
				<div class="alert alert-success">
				  <button type="button" class="close" data-dismiss="alert">&times;</button>
				  <strong>注册成功，请登录</strong>
				</div>
			</c:if>
			  <div class="control-group">
			    <label class="control-label" for="inputEmail"><i class="icon-asterisk" style="font-size:8px;"></i>请输入账户邮箱</label>
			    <div class="controls">
			      <input type="text" id="email" placeholder="邮箱" name="user.email">
			    </div>
			  </div>
			  <div class="control-group">
			    <label class="control-label" for="inputPassword"><i class="icon-asterisk" style="font-size:8px;"></i>请输入密码</label>
			    <div class="controls">
			      <input type="password" id="pswd" placeholder="密码" name="user.pswd">
			    </div>
			  </div>
			  <div class="control-group">
			    <div class="controls">
			      <label class="checkbox">
			        <input type="checkbox" name="remeberme" value="yes">记住我<br>
			      </label>
			      <button type="button" class="btn btn-warning login">登录</button>
			      &nbsp;&nbsp;&nbsp;<a href="/findPswd.action">忘记密码？</a>
			    </div>
			  </div>
			</form>
		</div>
		
		<%@ include file="include/foot.jsp" %>
	</div>
	<script src="js/validate/jquery.validate.js"></script>
    <script src="js/sha.js"></script>
    <script>
    	$(function(){
    		$(".fm").validate({
    			rules:{
    				'user.email':{
    					required:true,
    					email:true
    				},
    				'user.pswd':{
    					required:true,
    					minlength:6
    				}
    			},
    			messages:{
    				'user.email':{
    					required:'请输入电子邮件地址',
    					email:'电子邮件格式错误'
    				},
    				'user.pswd':{
    					required:"请输入密码",
    					minlength:"密码至少六位"
    				}

    			}
    		});
    		$(".login").click(function(){
    			if($("#pswd").val()!=""){/*阻止空密码被加密*/
	    			$("#pswd").val(CryptoJS.SHA1($("#pswd").val()));
    			}
    			/*此时是二次加密
    			 alert(CryptoJS.SHA1($("#pswd").val())); */
    			/* alert($("#pswd").val()); */
    			$(".fm").submit();
    		});
    	});
    </script>
</body>
</html>